//
//  HeroUsed.cpp
//  FruitCrush
//
//  Created by gaoyu on 15/7/30.
//
//

#include "HeroUsed.h"
#include "AttackAction.h"
#include "HeroBeauty.h"
#include "HeroFighter.h"

#define    HEALTH_NUM    (10)
#define    BOMB_DAMGAGE  (100)

static HeroUsed *s_SharedHeroUsed = nullptr;

HeroUsed* HeroUsed::getInstance()
{
    if (!s_SharedHeroUsed)
    {
        s_SharedHeroUsed = new (std::nothrow) HeroUsed();
        CCASSERT(s_SharedHeroUsed, "FATAL: Not enough memory");
        s_SharedHeroUsed->init();
    }
    
    return s_SharedHeroUsed;
}

HeroUsed::HeroUsed()
{
	heroFightType = UserDefault::getInstance()->getIntegerForKey(HEROS_FIGHT_TYPE_KEY, 0);
}

bool HeroUsed::init(void)
{
    return true;
}

HeroUsed::~HeroUsed(void)
{
    
    s_SharedHeroUsed = nullptr;
}
void HeroUsed::setHeroFightType(int type)
{
	heroFightType = type;
}

int HeroUsed::getDamageByType(int type)
{
	switch (heroFightType) {
		case 0:{
			switch (type) {
				case SwordAttack:
					return HeroBeauty::getInstance()->getSwordValue();
				case ArrowAttack:
					return HeroBeauty::getInstance()->getArrowValue();
				case FireAttack:
					return HeroBeauty::getInstance()->getFireValue();
				case LightAttack:
					return HeroBeauty::getInstance()->getLightValue();
				case HealthAttack:
					return HEALTH_NUM;
				case BombAttack:
					return BOMB_DAMGAGE;
				default:
					break;
			}
		}
			break;
		case 1:{
			switch (type) {
				case SwordAttack:
					return HeroFighter::getInstance()->getSwordValue();
				case ArrowAttack:
					return HeroFighter::getInstance()->getArrowValue();
				case FireAttack:
					return HeroFighter::getInstance()->getFireValue();
				case LightAttack:
					return HeroFighter::getInstance()->getLightValue();
				case HealthAttack:
					return HEALTH_NUM;
				case BombAttack:
					return BOMB_DAMGAGE;
				default:
					break;
			}
		}
			break;
		default:
			break;
	}

    return 0;
}

int HeroUsed::getHeroHealth()
{
	switch (heroFightType) {
		case 0:
			return HeroBeauty::getInstance()->getHealthValue();
		case 1:
			return HeroFighter::getInstance()->getHealthValue();
		default:
			break;
	}
    return 60;
}



